#include <iostream>

using namespace std;

/*
【题目222】定义一个哺乳动物Mammal类，再由此派生出狗Dog类，二者都定义SpeakO)
成员函数，基类中定义为虚函数，定义一个Dog类的对象，调用SpeakO函数，观察运行结果。
*/

class Mammal
{
public:
    virtual void Speak()
    {
        cout << "Mammal speak" << endl;
    }
};

class Dog : public Mammal
{
public:
    void Speak()
    {
        cout << "Dog speak" << endl;
    }
};

void Speak(Mammal &m)
{
    m.Speak();
}

int main()
{
    Mammal mammal;
    Dog dog;
    Speak(mammal);
    Speak(dog);

    return 0;
}